﻿#pragma once

#include "Misc/EngineEditorMacros.h"
#include "EditorWindowViewModel.h"
#include "Math/Color.h"
#include "Ability/EditorAbilityModel.h"
#include "Ability/EditorAbilityViewModel.h"
#include "EditorMainWindowViewModel.m.h"

class RWindow;  
class RTexture2D;
class REditorWindowModel;
class REditorMainWindowModel;
class RWidget;
class REditorSplitableLayoutViewModel;
class REditorSideBarViewModel;
class REditorPanelViewModel;
class REditorStatusBarViewModel;
class REditorNotificationViewModel;
class REditorMenuBarViewModel;

//view model of main window
RCLASS(ExtraHeader=["Widgets/Splitable/EditorSplitableLayoutViewModel.h","AbilityGroup/SideBar/EditorSideBarViewModel.h","AbilityGroup/Panel/EditorPanelViewModel.h","StatusBar/EditorStatusBarViewModel.h","Notification/EditorNotificationViewModel.h","Menubar/EditorMenuBarViewModel.h"])
class ENGINEEDITOR_API REditorMainWindowViewModel : public REditorWindowViewModel
{
    ROBJECT

public:
    REditorMainWindowViewModel();

    void BindModel(TSharedObjectPtr<REditorWindowModel> InModel) override;

protected:
    TWeakObjectPtr<REditorMainWindowModel> Model;
public:

    //margin to left window border
    const float MenuLeftMargin = 40;
    const float MenuWidth = 300; 

    //layout controll buttons at window right top
    const float LayoutControlButtonSize = 24;
    const float LayoutControlButtonPadding = 5;
    const float LayoutControlButtonRadius = 4;
    const float LayoutControlButtonImageSize = 14;
    const SColor LayoutControlButtonBackgroundColor = SColor::FromHexRGB(0x373737);

    TSharedObjectPtr<RTexture2D> GetMainSideBarToggleButtonImage() const;
    TSharedObjectPtr<RTexture2D> GetPanelToggleButtonImage() const;
    TSharedObjectPtr<RTexture2D> GetSecondarySideBarToggleButtonImage() const;
    void ToggleMainSideBar();
    void TogglePanel();
    void HidePanel();
    void ToggleSecondarySideBar();

    //window body layout 
    bool IsActivityBarVisible() const;
    EActivityBarPostion GetActivityBarPostion() const;
    const float ActivityBarWidth = 50;
    
    // bool IsMainSideBarVisible() const;
    // bool IsSecondarySideBarVisible() const;
    // bool IsPanelVisible() const;
  

    const float MinEditAreaWidth = 100;
    const float MinEditAreaHeight = 100;
    
    //body layout spliter drag
    const float DragSpliterSize = 4;
    const SColor DragSpliterHighlightColor = SColor::FromHexRGB(0x0078D4);
    TWeakObjectPtr<RWidget> DraggingSpliter;
    TWeakObjectPtr<RWidget> HorvoringSpliter;
    float DraggingSpliterFirstSize = 0; //size of first widget before start dragging
    float DraggingSpliterSecondSize = 0; //size of second widget before start dragging



    //activity bar
    const float ActivityButtonHeight = 50;
    const float ActivityButtonImageSize= 30; 
    int64_t GetActivityAbilityTabsCount() const;
    float GetActivityAbilityTabsHeight() const;
    void OnActivityBarTabClicked(int64_t InIndex);
    //TDelegate<void> OnSelectedActivityAbilityTabIndexChanged;
    const float ActivityButtonHighlightWidth=3;
    const SColor ActivityButtonHighlightColor=SColor::FromHexRGB(0x0078D4);
    bool IsActivityBarTabHighlight(int64_t InIndex) const;
    TSharedObjectPtr<RTexture2D> GetActivityAbilityTabIcon(int64_t InIndex) const;

    TSharedObjectPtr<REditorSplitableLayoutViewModel> GetBodyLayout();

    //主侧边栏
    TSharedObjectPtr<REditorSideBarViewModel> GetMainSideBar() const;

    //副侧边栏
    TSharedObjectPtr<REditorSideBarViewModel> GetSecondarySideBar() const;

    //输出面板
    TSharedObjectPtr<REditorPanelViewModel> GetPanel() const;

    //状态栏
    TSharedObjectPtr<REditorStatusBarViewModel> GetStatusBar() const;

    //通知
    TSharedObjectPtr<REditorNotificationViewModel> GetNotification() const; 

    //菜单栏
    TSharedObjectPtr<REditorMenuBarViewModel> GetMenuBar() const;

protected:


    TSharedObjectPtr<RTexture2D> MainSideBarToggleButtonImage_Show;
    TSharedObjectPtr<RTexture2D> MainSideBarToggleButtonImage_Hide;
    TSharedObjectPtr<RTexture2D> PanelToggleButtonImage_Show;
    TSharedObjectPtr<RTexture2D> PanelToggleButtonImage_Hide;
    TSharedObjectPtr<RTexture2D> SecondarySideBarToggleButtonImage_Show;
    TSharedObjectPtr<RTexture2D> SecondarySideBarToggleButtonImage_Hide;

    
    RFIELD()
    TSharedObjectPtr<REditorSplitableLayoutViewModel> BodyLayout;


    RFIELD()
    TSharedObjectPtr<REditorSideBarViewModel> MainSideBar;

    RFIELD()
    TSharedObjectPtr<REditorSideBarViewModel> SecondarySideBar;

    RFIELD()
    TSharedObjectPtr<REditorPanelViewModel> PanelViewModel;

    RFIELD()
    TSharedObjectPtr<REditorStatusBarViewModel> StatusBarViewModel;

    RFIELD()
    TSharedObjectPtr<REditorNotificationViewModel> NotificationViewModel; 

    RFIELD()
    TSharedObjectPtr<REditorMenuBarViewModel> MenuBarViewModel;
};